// conf/conf_mysql.go
package conf

import "fmt"

type Mysql struct {
	User              string `yaml:"user"`
	Pwd               string `yaml:"pwd"`
	Host              string `yaml:"host"`
	Port              int    `yaml:"port"`
	Db                string `yaml:"db"`
	Timeout           string `yaml:"timeout"`
	ReconnectionTimes int    `yaml:"reconnection_times"` // 重连次数
	ReconnectTime     int    `yaml:"reconnect_time"`     //  重连的间隔时间单位秒
}

func (m Mysql) Dsn() string {
	return fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local&timeout=%s",
		m.User, m.Pwd, m.Host, m.Port, m.Db, m.Timeout)
}
